<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>申请修改</title>
    <link rel="stylesheet" type="text/css" href="../../../../css/aui/aui.css" />
    <link rel="stylesheet" type="text/css" href="../../../../css/html/issued/post_your_want_frm.css" />
    <style>

    </style>
</head>

<body>
    <div id="app">
        <div class="aui-content aui-margin-b-15">
            <ul class="aui-list aui-form-list">
                <li class="aui-list-item" @click="openWork()">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">更改工种</div>
                        <div class="aui-list-item-input">
                            <input type="text" v-model="info.work_cate_name" disabled placeholder="请选择">
                        </div>
                    </div>
                </li>
            </ul>

            <div class="aui-content-padded">
                <div style="margin:1rem 0 0.5rem 0;">上传证书照片<small style="font-size:0.5rem;color:#B7B7B7;">(最多可上传三张图，图片大小不要超过2MB)</small></div>
                <div class="up_image_box">
                    <div class="up_image" onclick="addImg(this,0)">
                        <img src="../../../../image/icon/shangchuan.png" style="width:40%" alt="">
                    </div>
                    <div class="up_image" onclick="addImg(this,1)">
                        <img src="../../../../image/icon/shangchuan.png" style="width:40%" alt="">
                    </div>
                    <div class="up_image" onclick="addImg(this,2)">
                        <img src="../../../../image/icon/shangchuan.png" style="width:40%" alt="">
                    </div>
                </div>

                <div style="margin:1rem 0 0.5rem 0;">申请概述 <small> (选填项)</small></div>
                <textarea name="" id="" class="textarea" v-model="info.reason" placeholder="请详细描述申请原由"></textarea>
                <div class="btn" @click="submit()" style="width:100%;">立即提交</div>
            </div>

        </div>
    </div>
</body>
<script src="../../../../script/api.js" charset="utf-8"></script>
<script src="../../../../script/aui/aui-tab.js" charset="utf-8"></script>
<script src="../../../../script/common/jquery-3.3.1.min.js" charset="utf-8"></script>
<script src="../../../../script/common/check.js" charset="utf-8"></script>
<script src="../../../../script/common/common.js" charset="utf-8"></script>
<script src="../../../../script/common/config.js" charset="utf-8"></script>
<script src="../../../../script/common/vue.min.js" charset="utf-8"></script>
<script>
    apiready = function() {
        api.parseTapmode();
        vm.init();
    }

    var vm = new Vue({
        el: "#app",
        data: {
            userInfo: {},
            info: {
                user_id: '',
                work_cate_id: '',
                work_cate_name: '',
                certificate_array: [],
                reason: '',
                user_type: '',
            }
        },
        methods: {
            init() {
                this.userInfo = get_local('userInfo');
                this.info.user_id = this.userInfo.user_id;
                this.info.user_type = this.userInfo.user_type;
            },
            submit() {
                if (!is_define(this.info.work_cate_name)) {
                    $toast("请选择工种");
                    return;
                } else if (this.info.certificate_array.length === 0) {
                    $toast("请上传证书");
                    return;
                }
                _ajax(Config.api.UserApplyWorkCate, this.info, function(ret) {
                    if (ret.code === 200) {
                        $toast("提交成功");
                        setTimeout(function() {
                            close_w();
                        }, 1000);
                    }
                });
            },
            openWork() {
                var url = '../../../city/cate_win.html';
                api.openFrame({
                    name: 'mask',
                    url: url,
                    rect: {
                        x: 0,
                        y: api.winHeight - api.frameHeight,
                        w: 'auto',
                        h: 'auto'
                    },
                    bgColor: 'rgba(0,0,0,0.5)',
                    pageParam: {
                        name: api.winName,
                        frameName: api.frameName,
                    }
                });
            },
        }
    });

    function addImg(e, i) {
        imageUpload(Config.api.ImageUploadPrivacy, function(ret) {
            $(e).find('img').attr('src', ret.data.imgurl).css({'width': '100%', 'height': '100%'});
            vm.info.certificate_array[i] = ret.data.imgurl;
        });
    }

    function setWork(oParent, oChild) {
        vm.info.work_cate_name = oParent.work_cate_name + '/' + oChild.work_cate_name;
        vm.info.work_cate_id = oChild.work_cate_id;
    }
</script>

</html>
